<form id="handlePermissionAllotForm">
    <input type="hidden" name="menuPermissionId" value="${menuPermissionId}">
    <div class="row" id="handlePermissoinBtns" style="overflow:auto;margin-right:0px;">
    <#list nowMenuAllHandlePermission as mahp>
        <div class="col-lg-6 col-sm-6 col-xs-6">
            <div class="checkbox">
                <label>
                    <input type="checkbox" name="handlePermissionId" value="${mahp.id}" class="inverted"  ${mahp.isForbidden?string("disabled","")}>
                    <span class="text">${mahp.name}</span>
                </label>
            </div>
        </div>
    </#list>
</div>
<div class="col-lg-12 bordered-top-3 bordered-palegreen">
    <div class="col-lg-5">
        <a class="btn btn-yellow btn-xs btn-mini margin-top-10" onclick="checkAllHp()">全选</a>
        <a class="btn btn-magenta btn-xs btn-mini margin-top-10" onclick="unCheckAllHp()">反选</a>
        <a class="btn btn-azure btn-xs btn-mini margin-top-10" onclick="checkOtherAllHp()">全不选</a>
    </div>
</div>
</form>
<script type="text/javascript">

    $("#handlePermissoinBtns").height($(window).height() - 463);

    if($("#config").val()){
        var menuPermissionId=$("[name='menuPermissionId']").val();
        var config=JSON.parse($("#config").val());
        var roleName = $("#defaultRoles").val();
        if(config[roleName]){
            for(var i=0,len=config[roleName].length;i<len;i++){
                if(config[roleName][i].menuId==menuPermissionId){
                    var handleIds=config[roleName][i].handleIds;
                    for(var j=0,len_j=handleIds.length;j<len_j;j++){
                        $("#handlePermissionAllotForm [value='"+handleIds[j]+"']").map(function (index, chk) {
                            chk.checked=true;
                        });
                    }
                }
            }
        }
    }
    /**
     * 全选
     */
    function checkAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = true;
        });
    }

    /**
     * 反选
     */
    function unCheckAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = !chk.checked;
        });
    }

    /**
     * 全不选
     */
    function checkOtherAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = false;
        });
    }
</script>